package server

import (
	"github.com/zeromicro/go-zero/rest"
	"payme3000/api_gateway/internal/config"
	"payme3000/api_gateway/internal/logic"
	"payme3000/api_gateway/internal/server/router"
	"payme3000/framework/base"
	"payme3000/pb"
)

type Server struct {
	base.Server
	pb.UnimplementedApiGatewayServer

	cfg   *config.Config
	logic *logic.Logic
}

func NewServer(
	cfg *config.Config,
	logic *logic.Logic,
) *Server {
	s := &Server{
		cfg:   cfg,
		logic: logic,
	}

	// 启用api server功能
	s.RouterRegister = []base.IRouter{
		router.NewDefaultRouter(cfg),
	}
	s.ApiServerRunOptionList = append(s.ApiServerRunOptionList, rest.WithCors())

	return s
}
